package org.samoji.sji.model;

import java.math.BigDecimal;

import org.samoji.sji.profTokenizer.Token.Type;

public class BinExpr extends Expr {
	protected Type operation;
	protected Expr left;
	protected Expr right;

	public BinExpr() {;}

	public BinExpr(Type operation, Expr left, Expr right) {
		this.operation = operation;
		this.left = left;
		this.right = right;
	}
	
	@Override
	public BigDecimal evaluate(Env env) {
		switch(operation) {
		case Plus:
			return new PlusBinExpr(left, right).evaluate(env);
			
		case Minus:
			return new MinusBinExpr(left, right).evaluate(env);
			
		case Times:
			return new TimesBinExpr(left, right).evaluate(env);
			
		case Div:
			return new DivideBinExpr(left, right).evaluate(env);
			
		default:
			throw new RuntimeException("run-time: operation not implemented");
		}
	}
}